<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2022/3/24
 * Time: 16:33
 */

namespace app\api\validate;
use think\Validate;

class Teacher extends Validate
{
    public function checkMobile($mobile)
    {
        if($mobile!='')
        {
            if(preg_match("/^1[34578]\d{9}$/", $mobile)){
                return true;
            }
            else
            {
                return false;
            }
        }
        return true;

    }
    protected $rule = [
        'head_avatar'  => 'require',
        'name'  => 'require',
        'type'  => 'require',
        'sex_data'  => 'require',
        'born_time'  => 'require',
        'practitioner_time'  => 'require',
        'character'  => 'require',
        'height'  => 'require',
        'weight'  => 'require',
        'hometown'  => 'require',
        'nationality'  => 'require',
        'id_card'  => 'require|unique:teacher',
        'education'  => 'require',
        'city'  => 'require',
        'state'  => 'require',
        'payment_method'  => 'require',
        'account_name'  => 'require',
        'account'  => 'require',
        'mobile'  => 'checkMobile',


    ];

    /**
     * 提示消息
     */
    protected $message = [

        'head_avatar.require' => '头像不能为空',
        'name.require' => '姓名不能为空',
        'type.require' => '老师类型不能为空',
        'sex_data.require' => '性别不能为空',
        'born_time.require' => '出生年月不能为空',
        'practitioner_time.require' => '出生年月不能为空',
        'character.require' => '性格类型不能为空',
        'height.require' => '身高不能为空',
        'weight.require' => '体重不能为空',
        'hometown.require' => '籍贯不能为空',
        'nationality.require' => '民族不能为空',
        'id_card.require' => '身份证不能为空',
        'id_card.unique' => '身份证已存在',
        'education.require' => '学历不能为空',
        'city.require' => '所在城市不能为空',
        'state.require' => '类型不能为空',
        'payment_method.require' => '收款方式不能为空',
        'account_name.require' => '账号名不能为空',
        'account.require' => '账号不能为空',
        'mobile.checkMobile' => '手机格式不正确',

    ];
}